package com.glodon.paas.asyn;

import org.junit.Test;

import com.glodon.paas.util.ObjectUtil;
import com.glodon.paas.util.asyn.AsynWorker;
import com.glodon.paas.util.asyn.AsynWorkerExecutorImpl;

/**
 * 掩饰异常日志
 * 
 * @author a
 */
public class AsynWorkerDemo {	
	static Class<?>[] types = new Class<?>[]{String.class, String.class,int.class, boolean.class};
	static Class<?>[] typesError = new Class<?>[]{String.class, String.class,int.class};
 
	@Test
	public void testShutdown() {
		 
	}
	
	// 工作方法
	public void longTimeMethod(String gar1, String arg2, int arg3, boolean arg4){
		System.out.println(Thread.currentThread().getName()+":gar1="+gar1+",arg2="+arg2+",arg3="+arg3);	
		ObjectUtil.sleep(1000, true);		
	};
	
	// 工作方法
	public void param1(){
		System.out.println(Thread.currentThread().getName()+"param1()");	
		ObjectUtil.sleep(1000, true);		
	};
	
	public static void main(String[] args) {
		AsynWorker worker = new AsynWorkerExecutorImpl(2,2);
		Class<?>[] types = new Class<?>[]{String.class, String.class,int.class, boolean.class};
		
		
		AsynWorkerDemo demo = new AsynWorkerDemo();
		worker.start();
		for(int i=0; i<1000; i++){
			worker.submit(demo, "longTimeMethod", new Object[]{""+i, "name_"+i,i,true}, types);
		}
		worker.shutdown();
		
	}
}
